declare @group_id int = 1
declare @parent_id int = 1004
declare @department_id int =1


insert APPLICATION_GROUP_RULE
select '7FACBBAA-1113-4D8D-B37D-F22646771F83',@group_id , id, 1, 'Y',@department_id from APPLICATION_OBJECT 
where 
PARENT_ID = @parent_id and 
--id='0307' and 
id not in (select OBJECT_ID from APPLICATION_GROUP_RULE where GROUP_ID = @group_id and DEPARTMENT_ID = @department_id) and 
ID not in ('0801','0303','0304')

--delete  APPLICATION_GROUP_RULE where OBJECT_ID = '0801' and GROUP_ID = 4

select * from APPLICATION_GROUP_RULE a, APPLICATION_OBJECT b
where 
GROUP_ID = 4 and 
a.OBJECT_ID= b.ID
and b.PARENT_ID = '17'

delete from server12.SMECustomer360.[dbo].[APPLICATION_OBJECT]
insert server12.SMECustomer360.dbo.[APPLICATION_OBJECT]
select * from [APPLICATION_OBJECT]

delete from server12.SMECustomer360.[dbo].[APPLICATION_GROUP_RULE]
insert server12.SMECustomer360.dbo.[APPLICATION_GROUP_RULE]
select * from [APPLICATION_GROUP_RULE]

delete from server12.SMECustomer360.[dbo].[APPLICATION_GROUP]
insert server12.SMECustomer360.dbo.[APPLICATION_GROUP]
select * from [APPLICATION_GROUP]

delete from server12.SMECustomer360.[dbo].[TBL_Product_Handbook_Product_Detail]
insert server12.SMECustomer360.dbo.[TBL_Product_Handbook_Product_Detail] ([Product_name]
      ,[Product_name_en]
      ,[Overview_product]
      ,[Condition_product]
      ,[Document_product]
      ,[X_selling_product]
      ,[Overview_product_en]
      ,[Condition_product_en]
      ,[Document_product_en]
      ,[X_selling_product_en])
select [Product_name]
      ,[Product_name_en]
      ,[Overview_product]
      ,[Condition_product]
      ,[Document_product]
      ,[X_selling_product]
      ,[Overview_product_en]
      ,[Condition_product_en]
      ,[Document_product_en]
      ,[X_selling_product_en] from [TBL_Product_Handbook_Product_Detail]

	  select * from TBL_HR where USER_NAME = 'duyennt3'